<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var none ="";
        var a = prompt("请输入层数：");
        a=parseInt(a);
        for (var i = 1; i <= a; i++) {
            for (var l = 1; l <=a-i; l++) {
                none +=" ";
            }
            for (var j = 1; j <= i*2-1; j++) {
               none += "*";
            }
            none += "\n";
        }
        window.alert(none);
    </script>
</body>
</html>